package pers.lance.firstweb.servlet;

import pers.lance.firstweb.dao.UserManager;
import pers.lance.firstweb.dao.UserManagerImpl;
import pers.lance.firstweb.processtor.DomProcesstor;
import pers.lance.firstweb.processtor.DomProcesstorWithDom4j;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "FindAllServlet", urlPatterns = "/findall")
public class FindAllServlet extends UserInterceptServlet {
    UserManager userManager = new UserManagerImpl();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        DomProcesstor domProcesstor = new DomProcesstorWithDom4j();
        try {
            domProcesstor.user2Html(userManager.findAllUsers(), response.getWriter());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        doPost(request, response);
    }
}
